package com.qf.sale.controller;

import com.github.pagehelper.PageInfo;
import com.qf.lw.pojo.GoodsPojo;
import com.qf.sale.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class GoodsController {
    @Autowired
    IGoodsService goodsService;
    @RequestMapping("queryGoods")
    public ModelAndView queryGoods(GoodsPojo goodsPojo){
        ModelAndView mv =new ModelAndView();
        List<GoodsPojo> list=goodsService.queryGoodsByPojo(goodsPojo);
        PageInfo<GoodsPojo>  pageInfo=new PageInfo<>(list);
//        mv.addObject("goodsList",list);
        mv.addObject("pageInfo",pageInfo);
        mv.addObject("goodsPojo",goodsPojo);
        mv.setViewName("goodsList");
        return  mv;
    }
    @RequestMapping("queryGoodsDetail")
    public ModelAndView queryGoodsDetail(String gid){
        ModelAndView mv =new ModelAndView();
        GoodsPojo goodsPojo=goodsService.queryGoodsDetail(gid);
        mv.addObject("goodsPojo",goodsPojo);
        mv.setViewName("product");
        return mv;
    }


}
